
let floor = Math.floor

export default class Randomer
{
    constructor(seed) 
    {
        this.mSeed = seed
    }
    
    setSeed(seed)
    {
        this.mSeed = seed
    }
    
    seededRandom(seed, min, max) 
    {
        seed = (seed * 9301 + 49297) % 233280
        
        const rand = seed / 233280

        return min + rand * (max - min)
    }

    random(min, max) 
    {
        min = min || 0
        max = max || 1

        let r = floor(this.seededRandom(this.mSeed, min, max))

        this.mSeed += floor(this.seededRandom(this.mSeed, 1, 100000))

        return r
    }
}
